home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
tdemo2.lha
/
ProgrammersInfo
/
DoorCode.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-05
|
10KB
|
560 lines
/* Tempest Door Code! */
//**********************
//***** Includes *****
//**********************
#include <proto/all.h>
#include <exec/types.h>
#include <time.h>
#include <stdio.h>
#include <ctype.h>
#include <devices/timer.h>
#include <devices/serial.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <exec/memory.h>
#include <stdarg.h>
#include <string.h>
#include <tempest/headers.h>
//************************
//***** ProtoTypes *****
//************************
int DoorStart(TEXT *);
int DOORIO(VOID);
VOID CloseStuff(VOID);
VOID Activity(BYTE,TEXT *);
VOID AlterTime(UWORD);
int CheckKey(VOID);
int CTRLC(VOID);
int CursorHotKey(VOID);
VOID Editor(TEXT *,int);
VOID GetPaths(TEXT *,int);
VOID GetStr(TEXT *,int);
VOID GetUserTime(TEXT *);
int GetValue(int);
int hotkey(TEXT *);
VOID input(TEXT *,int);
VOID inputAB(TEXT *,int);
VOID LineInput(TEXT *,TEXT *,int);
VOID LineInputAB(TEXT *,TEXT *,int);
VOID LineInputHide(TEXT *,TEXT *,int);
VOID LineInputHideAB(TEXT *,TEXT *,int);
VOID MarkFile(TEXT *);
VOID LoadSystemData(VOID);
VOID LOG(TEXT *);
VOID SLOG(TEXT *);
VOID DEBUGLOG(TEXT *);
VOID USERLOG(TEXT *);
int MORE(VOID);
int Pause(VOID);
VOID pl(TEXT *);
VOID pl(TEXT *,...);
int Random(int);
VOID SetValue(int,int);
VOID showfile(TEXT *);
VOID UserTime(int);
VOID WriteFile(TEXT *,TEXT *);
VOID ZmodemDownload(TEXT *);
VOID ZUpload(VOID);
//*********************
//***** Structs *****
//*********************
struct MyMessage
{
struct Message Msg; // for Exec message routines
ULONG Command; // Command to be executed.
TEXT *text1,
*text2,
*text3;
int Value1,
Value2;
ULONG LongValue;
LONGBITS Flags;
int carrier;
struct User *User;
struct SystemData *SystemData;
struct NodeData *NodeData;
struct Today *Today;
};
struct MyMessage send;
struct MsgPort *MyPort = NULL;
struct MyMessage *msg;
struct User *User;
char MyName[60],st[60]; // Variables for Port names.
//************************
//***** Door Start ***** // MUST BE INCLUDED IN ALL DOORS!
//************************
int DoorStart(TEXT *node)
{
struct MsgPort *HisPort;
send.carrier=0;
sprintf(st,"%s:TEMPEST_DOOR",node);
HisPort = FindPort(st);
if(HisPort==NULL) return (FALSE);
sprintf(MyName,"%s:DOOR_PORT",node);
MyPort = CreatePort(MyName,0L);
if(MyPort==NULL)
{
PutStr("Cant open port");
return(int)FALSE;
}
DOORIO();
User=*&send.User;
return (int)TRUE;
}
//********************
//***** DoorIO ***** // MUST BE INCLUDED IN ALL DOORS!
//********************
int DOORIO(VOID)
{
struct MsgPort *HisPort;
if(send.carrier) return(0);
HisPort = FindPort(st);
if(HisPort!=NULL)
{
send.Msg.mn_Node.ln_Type = NT_MESSAGE;
send.Msg.mn_Length = sizeof(send);
send.Msg.mn_ReplyPort = MyPort;
send.carrier=0;
PutMsg((struct MsgPort *)HisPort,(struct Message *)&send);
Wait(1 << MyPort->mp_SigBit);
GetMsg(MyPort);
if(send.carrier) CloseStuff();
return(1);
}
return(0);
}
//*************************
//***** Close Stuff ***** // MUST BE INCLUDED IN ALL DOORS!
//*************************
VOID CloseStuff(VOID)
{
send.Command=999;
DOORIO();
while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
if(MyPort) DeletePort(MyPort);
exit(0);
}
//**********************
//***** Activity ***** // Command 44
//**********************
VOID Activity(BYTE act,TEXT *s)
{
send.Command=44;
send.Value1=act;
send.text1=s;
DOORIO();
}
//***********************
//***** AlterTime ***** // Command 41
//***********************
VOID AlterTime(UWORD opt)
{
send.Command=41;
send.Value1=(int)opt;
DOORIO();
}
//***********************
//***** Check Key ***** // Command 15
//***********************
int CheckKey(VOID)
{
send.Command=15;
send.Value2=0;
DOORIO();
return(send.Value2);
}
//*************************
//***** CTRLC CHECK ***** // Command 10
//*************************
int CTRLC(VOID)
{
send.Command=10;
DOORIO();
return(send.Value1);
}
//***************************
//***** Cursor HotKey ***** // Command 17
//***************************
int CursorHotKey(VOID)
{
send.Command=17;
DOORIO();
return(send.Value1);
}
//********************
//***** Editor ***** // Command 73
//********************
VOID Editor(TEXT *Filename,int maxlength)
{
send.Command=73;
send.Value1=maxlength;
send.text1=Filename;
DOORIO();
}
//***********************
//***** Get Paths ***** // Command 30
//***********************
VOID GetPaths(TEXT *s,int opt)
{
send.Command=30;
send.Value1=opt;
strcpy(s,NULL);
send.text1=s;
DOORIO();
}
//*********************************
//***** GetStr (Get String) ***** // Command 33
//*********************************
VOID GetStr(TEXT *s,int opt)
{
send.Command=33;
send.Value1=opt;
strcpy(s,NULL);
send.text1=s;
DOORIO();
}
//***************************
//***** Get User Time ***** // Command 31
//***************************
VOID GetUserTime(TEXT *s)
{
send.Command=31;
send.text1=s;
DOORIO();
}
//***********************
//***** Get Value ***** // Command 34
//***********************
int GetValue(int opt)
{
send.Command=34;
send.Value1=opt;
DOORIO();
return(send.Value2);
}
//*********************
//***** Hot Key ***** // Command 16
//*********************
int hotkey(TEXT *character)
{
send.Command=16;
send.text1=character;
DOORIO();
return((int)character[0]);
}
//*******************
//***** Input ***** // Command 20
//*******************
VOID input(TEXT *mstring,int len)
{
send.Command=20;
send.Value1=len;
send.text1 =mstring;
DOORIO();
}
//****************************
//***** Input Ansi Bar ***** // Command 21
//****************************
VOID inputAB(TEXT *mstring,int len)
{
send.Command=21;
send.Value1=len;
send.text1 =mstring;
DOORIO();
}
//************************
//***** Line Input ***** // Command 22
//************************
VOID LineInput(TEXT *ostring,TEXT *mstring,int len)
{
send.Command=22;
send.Value1=len;
send.text1=mstring;
send.text2=ostring;
DOORIO();
}
//********************************
//***** Line Input Ansi Bar ***** // Command 23
//********************************
VOID LineInputAB(TEXT *ostring,TEXT *mstring,int len)
{
send.Command=23;
send.Value1=len;
send.text1=mstring;
send.text2=ostring;
DOORIO();
}
//*********************************
//***** Line Input (Hidden) ***** // Command 24
//*********************************
VOID LineInputHide(TEXT *oldstring,TEXT *newstring,int len)
{
send.Command=24;
send.Value1=len;
send.text1=newstring;
send.text2=oldstring;
DOORIO();
}
//*****************************************
//***** Line Input (Hidden) Ansi Bar ***** // Command 25
//*****************************************
VOID LineInputHideAB(TEXT *oldstring,TEXT *newstring,int len)
{
send.Command=25;
send.Value1=len;
send.text1=newstring;
send.text2=oldstring;
DOORIO();
}
//******************************
//***** Load System Data ***** // Command 74
//******************************
VOID LoadSystemData(VOID)
{
send.Command=74;
DOORIO();
}
//********************************
//***** LOG (Write to Log) ***** // Command 60
//********************************
VOID LOG(TEXT *outstring)
{
send.Command=60;
send.text1=outstring;
DOORIO();
}
//***************************************
//***** SLOG (Write to Sysop Log) ***** // Command 61
//***************************************
VOID SLOG(TEXT *outstring)
{
send.Command=61;
send.text1=outstring;
DOORIO();
}
//*****************************************
//***** de_bug (Write to debug Log) ***** // Command 62
//*****************************************
VOID DEBUGLOG(TEXT *outstring)
{
send.Command=62;
send.text1=outstring;
DOORIO();
}
//******************************************
//***** User Log (Write to User Log) ***** // Command 63
//******************************************
VOID USERLOG(TEXT *outstring)
{
send.Command=63;
send.text1=outstring;
DOORIO();
}
//*****************************************
//***** FLAG/MARK file for Download ***** // Command 51
//*****************************************
VOID MarkFile(TEXT *flagfile)
{
send.Command=51;
send.text1=flagfile);
DOORIO();
}
//*************************
//***** MORE PROMPT ***** // Command 72
//*************************
int MORE(VOID)
{
send.Command=72;
DOORIO();
return(send.Value1);
}
//*******************
//***** Pause ***** // Command 71
//*******************
int Pause(VOID)
{
send.Command=71;
DOORIO();
return(send.Value1);
}
//*****************************
//***** PL (Print Line) ***** // Command 1
//*****************************
VOID pl(TEXT *string)
{
send.Command=1;
send.text1=string;
DOORIO();
}
//*****************************
//***** PL (Print Line) ***** // Command 1 with a twist
//*****************************
VOID pl(TEXT *fmt,...)
{
va_list args;
TEXT s[255];
va_start(args,fmt);
vsprintf(s,fmt,args);
va_end(args);
send.Command=1;
send.text1=&s[0];
DOORIO();
}
//********************
//***** Random ***** // Command 75
//********************
int Random(int x)
{
send.Command=75;
send.Value1=x;
DOORIO();
return(send.Value1);
}
//***********************
//***** Set Value ***** // Command 43
//***********************
VOID SetValue(int opt1,int opt)
{
send.Command=43;
send.Value2=opt1;
send.Value1=opt;
DOORIO();
}
//***********************
//***** Show File ***** // Command 70
//***********************
VOID showfile(TEXT *mstring)
{
send.Command=70;
send.text1=mstring;
DOORIO();
}
//***********************
//***** User Time ***** // Command 31
//***********************
VOID UserTime(int x)
{
send.Command=31;
send.Value1=x;
DOORIO();
}
//************************
//***** Write File ***** // Command 69
//************************
VOID WriteFile(TEXT *ostring,TEXT *mstring)
{
send.Command=69;
send.text1=ostring;
send.text2=mstring;
DOORIO();
}
//*****************************
//***** Zmodem Download ***** // Command 52
//*****************************
VOID ZmodemDownload(TEXT *mstring)
{
send.Command=52;
send.text1=mstring;
DOORIO();
}
//***************************
//***** Zmodem Upload ***** // Command 53
//***************************
VOID ZUpload(VOID)
{
send.Command=53;
DOORIO();
}